package com.own.component.util.time;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * TimestampUtil
 *
 * @author chenxueli
 * @date 2023-07-27 16:09:00
 */
public class TimestampUtil {

    /**
     * 距离指定时间的毫秒
     *
     * @param endDate 指定时间
     * @return 距离指定时间的毫秒
     */
    public static long duration(LocalDateTime endDate) {
        return Duration.between(LocalDateTime.now(), endDate).toMillis();
    }

    /**
     * 今天剩余的毫秒
     *
     * @return 今天剩余的毫秒
     */
    public static long todayDuration() {
        return Duration.between(LocalDateTime.now(), LocalDateTimeUtil.endToday()).toMillis();
    }

    public static void main(String[] args) {
        var timestamp = todayDuration();
        System.out.println("timestamp = " + timestamp);
    }

}
